package com.sharemarking.wa.common;

public class ResponseParams<T>{

	private Integer errCode;
	private String errMsg;

	private T data;

	//private Map<String, Object> pageInfo;

	public Integer getErrCode() {
		return errCode;
	}

	public String getErrMsg() {
		return errMsg;
	}
	
	public T getData() {
		return data;
	}
	
	private ResponseParams(){
		
	}

//	public ResponseParams pageInfo(boolean hasNext, Integer pageIndex,
//			Integer pageSize, Long total) {
//		Map<String, Object> pageInfo = new HashMap<String, Object>();
//		pageInfo.put("hasNext", hasNext);
//		pageInfo.put("pageIndex", pageIndex);
//		pageInfo.put("pageSize", pageSize);
//		pageInfo.put("total", total);
//		this.setPageInfo(pageInfo);
//		return this;
//	}
	
	public static <DTO> ResponseParams<DTO> ok(DTO t){
		ResponseParams<DTO> param=new ResponseParams<DTO>();
		param.errCode=SysHttpStatus.SUCCESS.getStatus();
		param.errMsg=SysHttpStatus.SUCCESS.getMessage();
		param.data=t;
		return param;
	}
	
	public static <DTO> ResponseParams<DTO> error(SysHttpStatus status){
		ResponseParams<DTO> param=new ResponseParams<DTO>();
		param.errCode=status.getStatus();
		param.errMsg=status.getMessage();
		return param;
	}
	
	public static <DTO> ResponseParams<DTO> competitorError(String msg){
		ResponseParams<DTO> param=new ResponseParams<DTO>();
		param.errCode=SysHttpStatus.COMPETITOR_EXCEPTION.getStatus();
		param.errMsg=msg;
		return param;
	}
	
	public static <DTO> ResponseParams<DTO> requiredParamsIsMissing(String msg){
		ResponseParams<DTO> param=new ResponseParams<DTO>();
		param.errCode=SysHttpStatus.REQUIRED_PARAMS_IS_MISSING.getStatus();
		param.errMsg=SysHttpStatus.REQUIRED_PARAMS_IS_MISSING.getMessage() + ": " + msg;
		return param;
	}

    public static <DTO> ResponseParams<DTO> baiduError(String msg){
        ResponseParams<DTO> param=new ResponseParams<DTO>();
        param.errCode=SysHttpStatus.ERROR_BAIDU_RENLIAN.getStatus();
        param.errMsg=msg;
        return param;
    }
    public static <DTO> ResponseParams<DTO> backFeeError(String msg){
    	ResponseParams<DTO> param=new ResponseParams<DTO>();
    	param.errCode=SysHttpStatus.BACK_FEE_EXCEPTION.getStatus();
    	param.errMsg=msg;
    	return param;
    }

//	public static <DTO> ResponseParams<DTO> invalidSigniture() {
//		ResponseParams<DTO> param=new ResponseParams<DTO>();
//		param.errCode=SysHttpStatus.SIGN_INVALID.getStatus();
//		param.errMsg=SysHttpStatus.SIGN_INVALID.getMessage();
//		return param;
//	}
//
//    /**
//     * 请描述是哪个参数缺失
//     * @param msg 错误信息
//     * @return responseParams
//     */
//	public static <DTO> ResponseParams<DTO> requiredParamsIsMissing(String msg) {
//		ResponseParams<DTO> param=new ResponseParams<DTO>();
//		param.errCode=SysHttpStatus.REQUIRED_PARAMS_IS_MISSING.getStatus();
//		param.errMsg=SysHttpStatus.REQUIRED_PARAMS_IS_MISSING.getMessage() + "：" + msg;
//		return param;
//	}
//
	public static <DTO> ResponseParams<DTO> invalidUser() {
		ResponseParams<DTO> param=new ResponseParams<DTO>();
		param.errCode=SysHttpStatus.INVALID_USER.getStatus();
		param.errMsg=SysHttpStatus.INVALID_USER.getMessage();
		return param;
	}
//
//	public static <DTO> ResponseParams<DTO> alreadyRegist() {
//		this.setErrCode(SysHttpStatus.NOT_PERMISSIONS.getStatus());
//		this.setErrMsg(SysHttpStatus.NOT_PERMISSIONS.getMessage());
//		return this;
//	}
//
//    public ResponseParams isNotFindToken() {
//        this.setErrCode(SysHttpStatus.NOT_FIND_TOKEN.getStatus());
//        this.setErrMsg(SysHttpStatus.NOT_FIND_TOKEN.getMessage());
//        return this;
//    }
//
	public static <DTO> ResponseParams<DTO> isDataError(String msg) {
		ResponseParams<DTO> param=new ResponseParams<DTO>();
		param.errCode = SysHttpStatus.DATA_ERROR.getStatus();
		param.errMsg = msg;
		return param;
	}

}
